// import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { productid, systemid } from '../../atom/config';

interface Message {
	cookie: {
		uk: string;
		[key: string]: string
	};
	urls: {
		base: string;
		origin: string;
		url: string;
	};
	query: {};
	params: {};
	headers: {};
	captcha: string;
	value_title: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:e:\考核-2\kh\src\device-management-ygh\zj-000002\s004,action_id:' + action_id);

	const q = query(action_id, session_id, systemid);
	q.prepare('basic_data', ['value_no', 'value_title', 'value_name'], { productid, value_title: message.value_title }, 200, 1, [], []);
	const data = await q.exec();
	const res = data[0];

	log('Service end path:e:\考核-2\kh\src\device-management-ygh\zj-000002\s004,action_id:' + action_id);
	return {
		data: res
	};
}
